*Set directories below and output main tables and figures

global dataoutput		= "${path}data/"
global results		= "${path}figures/"


/***********************************************************************************/
/* Figure 1: Management Practices and Language Barriers in World Management Survey */
/***********************************************************************************/

	*Lower- and middle-income countries
	use "${dataoutput}Gravity.dta", clear

	local covars "gmt_diff col_dep_ever"

 	binscatter management comlang_ethno if incomelevel!="HIC", ///
	controls(_host* _mne* dist emp_firm `covars') ytitle("Management Score") ///
	xtitle("Common Language") savedata(${temp}bins1) replace

 	eststo LMIC: reg management comlang_ethno _host* _mne* dist emp_firm `covars' if incomelevel!="HIC"
	clear

	do "${temp}bins1"
	save "${temp}bins1.dta", replace
	
	*High-income
	use "${dataoutput}gravity.dta", replace

	binscatter management comlang_ethno if incomelevel=="HIC", ///
	controls(_host* _mne* dist emp_firm `covars') ytitle("Management Score") ///
	xtitle("Common Language") savedata(${temp}bins2) replace

 	eststo HIC: reg management comlang_ethno _host* _mne* dist emp_firm `covars' if incomelevel=="HIC"
	clear
	
	do "${temp}bins2"
	save "${temp}bins2", replace
	
	*Final figure
	use "${dataoutput}Gravity.dta", clear
	append using "${temp}bins1", gen(bins1)
	append using "${temp}bins2", gen(bins2)
	erase "${temp}bins1.dta"
	erase "${temp}bins2.dta"
	erase "${temp}bins1.do"
	erase "${temp}bins2.do"

	twoway (lfit management comlang_ethno if bins1 == 1, lp(solid) lc(gs2)) /// 
			(scatter management comlang_ethno if bins1 == 1, msymbol(Oh) msize(small) mc(gs2)) ///
			(lfit management comlang_ethno if bins2 == 1,lpattern("-") lc(gs7)) ///
			(scatter management comlang_ethno if bins2 == 1, msymbol(Th) msize(small) mc(gs7)) ///
			, ytitle("WMS Management Score") xtitle("Common Language") ///
			legend(label(2 "Low- and Middle-Income Countries") ///
			label(4 "High-Income economies") row(2) ring(0) pos(4)) ///
			legend(order (2 4) size(vsmall)) ///
			xlabel(-.25(0.25)1) 
	graph export "${results}/Fig1.pdf", as(pdf) replace

/***********************************************************************************/
/************************* Table 1: Summary Statistics *****************************/
/***********************************************************************************/


	*Constructed row-by-row; close insets
	
	*Row 1
	{
	use "${dataoutput}Firms_salary_sheets.dta", clear
	bysort companyid: egen Nemp = total(num)
	collapse (mean) Nemp lang_sample, by(companyid)
	drop if companyid=="wvw232"
	replace Nemp=. if Nemp==0

	*for the firms for which we don't have data, we use the following links
	replace Nemp=126 if companyid=="gxi433"
	replace Nemp=224 if companyid=="egs457" // https://www.globalsuzuki.com/globalnews/2020/0323.html
	replace Nemp=60 if companyid=="wqy314" // https://asia.nikkei.com/Business/Taiyo-Nippon-Sanso-to-turn-out-industrial-gases-in-Myanmar
	
	sum Nemp if lang_sample==1 | (companyid=="bqe796"| companyid=="gxi433" | companyid=="ksb204")	
	g a=string(r(mean), "%2.1fc")
	g b=string(r(sd), "%2.1fc")

	egen Nfirms=nvals(companyid) if !missing(Nemp)
	sum Nfirms
	g k=string(r(mean), "%2.0fc")
	egen total_emp=total(Nemp)
	summ total_emp
	g s=string(r(mean), "%2.0fc")
	gen z = 1
	label define emp_all 1"Total Employees \textdagger"
	label values z emp_all
	order z a b k s
	keep z a b k s
	
	tempfile r1
	save `r1'
	}
	
	*Row 2
	{
	use "${dataoutput}DMs.dta", clear
	keep if !regexm(id, "www")
	egen NDMs=nvals(id)
	bysort companyid: egen nfms=nvals(manager_b)
	bysort companyid (nfm): replace nfm=nfm[1] if missing(nfm)
	g num=1
	egen total_dms=total(num) if !missing(manager_b)
	collapse (mean) total_dms nfms, by(companyid)
	sum nfms
	g a=string(r(mean), "%2.1fc")
	g b=string(r(sd), "%2.1fc")
	g k=string(r(N), "%2.0fc")
	egen total_fms=total(nfms)
	sum total_fms
	g s=string(r(mean), "%2.0fc")
	gen z = 1
	label define emp_fm 1"Number"
	label values z emp_fm
	order z a b k s
	keep z a b k s		
	
	tempfile r2
	save `r2'
	}
	
	*Row 3
	{
	use "${dataoutput}DMs_salary_sheets.dta", clear
	keep if pos=="Expat"
	merge m:1 companyid using "${tmp}firms_labor_survey_sample.dta"
	keep if _merge==3
	*keep if lang_sample==1
	egen Nfm=nvals(companyid) if !missing(monthly_tot_USD)
	summ Nfm
	g k=string(r(mean), "%2.0fc")
	gen num=1 if !missing(monthly_tot_USD)
	egen Nfm2=total(num)
	summ Nfm2
	g s=string(r(mean), "%2.0fc")
	sum monthly_tot_USD
	g a=string(r(mean), "%2.0fc")
	g b=string(r(sd), "%2.0fc")
	gen z = 1
	label define w_fm 1"Monthly Wage (USD) \textdagger"
	label values z w_fm
	order z a b k s
	keep z a b k s	
	
	tempfile r3
	save `r3'
	}
	
	*Row 4-7
	{
	use "${dataoutput}FMs.dta", clear
	gen age=2019-birthyear
	egen Nfm2=nvals(comp)
	summ Nfm2
	g k=string(r(mean), "%2.0fc")
	egen Nfm=nvals(FMid)
	summ Nfm
	g s=string(r(mean), "%2.0fc")
	sum age
	g a=string(r(mean), "%2.1fc")
	g b=string(r(sd), "%2.1fc")
	gen z = 1
	label define age_fm 1 "Age (yrs)"
	label values z age_fm 
	
	preserve
	order z a b k s
	keep z a b k s	
	
	tempfile r4
	save `r4'
	restore
	
	drop z a b
	sum workyear_allFM
	g a=string(r(mean), "%2.1fc")
	g b=string(r(sd), "%2.1fc")
	gen z = 1
	label define ten_fm 1 "Tenure at company (yrs)"
	label values z ten_fm 
	
	preserve
	order z a b k s
	keep z a b k s	
	
	tempfile r5
	save `r5'
	restore
	drop z a b
	
	sum workyear_myFM
	g a=string(r(mean), "%2.1fc")
	g b=string(r(sd), "%2.1fc")
	gen z = 1
	label define ten_fm2 1 "Tenure at company in Myanmar (yrs)"
	label values z ten_fm2 
	preserve
	order z a b k s
	keep z a b k s	
	
	tempfile r6
	save `r6'
	restore
	drop z a b 
	
	sum FMeng_score_tot
	g a=string(r(mean), "%2.1fc")
	g b=string(r(sd), "%2.1fc")
	gen z = 1
	label define eng_fm 1"English score (\%)"
	label values z eng_fm 
	order z a b k s
	keep z a b k s	
	
	tempfile r7
	save `r7'
	}
	
	*Row 8
	{
	use "${dataoutput}Firms_HR_response.dta", clear
	keep if level=="proficient" // decided
	egen Nfm2=nvals(company) if !missing(share_f)
	summ Nfm2
	g k=string(r(mean), "%2.0fc")
	egen Nfm=total(total_f) if total_d>=0
	summ Nfm
	g s=string(r(mean), "%2.0fc")
	replace s="-"
	sum share_f if total_d>=0
	g a=string(r(mean)*100, "%2.1fc")
	g b=string(r(sd)*100, "%2.1fc")
	gen z = 1
	label define hreng_fm 1 "Share proficient in English (\%) \textdaggerdbl"
	label values z hreng_fm 
	order z a b k s
	keep z a b k s	
	
	tempfile r8
	save `r8'
	}
	
	*Row 9
	{
	use "${dataoutput}DMs.dta", clear
	keep if !regexm(id, "www")
	egen N_DM=nvals(id) 
	egen Nfirms3=nvals(companyid)
	summ Nfirms3
	g k=string(r(mean), "%2.0fc")
	egen Nfirms31=nvals(id)
	summ Nfirms31
	g s=string(r(mean), "%2.0fc")
	gen num=1 
	collapse (count) num (first) k s, by(companyid)
	sum num
	g a=string(r(mean), "%2.1fc")
	g b=string(r(sd), "%2.1fc")
	gen z = 1
	label define w_dm 1"Number"
	label values z w_dm
	order z a b k s
	keep z a b k s	
	
	tempfile r9
	save `r9'
	}
	
	*Row 10
	{
	use "${dataoutput}DMs.dta", clear
	keep if !regexm(id, "www")
	egen N_DM=nvals(id) 
	egen Nfirms3=nvals(companyid)
	summ Nfirms3
	g k=string(r(mean), "%2.0fc")
	egen Nfirms31=nvals(id)
	summ Nfirms31
	g c=string(r(mean), "%2.0fc")
	sum salary_USD
	g a=string(r(mean), "%2.0fc")
	g b=string(r(sd), "%2.0fc")
	g s=string(r(N), "%2.0fc")
	gen z = 1
	label define w_dm 1"Monthly Wage (USD)"
	label values z w_dm
	order z a b k s
	keep z a b k s	
	
	tempfile r10
	save `r10'
	}
	
	*Row 11-12
	{
	use "${dataoutput}DMs.dta", clear
	keep if !regexm(id, "www")	
	egen Nfirms3=nvals(companyid)
	summ Nfirms3
	g k=string(r(mean), "%2.0fc")
	egen Ndm=nvals(id)
	summ Ndm
	g c=string(r(mean), "%2.0fc")
	sum ageR0
	g a=string(r(mean), "%2.1fc")
	g b=string(r(sd), "%2.1fc")
	g s=string(r(N), "%2.0fc")
	gen z = 1
	label define age_dm 1"Age (yrs)"
	label values z age_dm
	
	preserve
	order z a b k s
	keep z a b k s	
	
	tempfile r11
	save `r11'
	restore
	
	drop z a b s
	sum tenure
	g a=string(r(mean), "%2.1fc")
	g b=string(r(sd), "%2.1fc")
	g s=string(r(N), "%2.0fc")
	gen z = 1
	label define ten_dm 1 "Tenure at company (yrs)"
	label values z ten_dm 
	order z a b k s
	keep z a b k s	
	
	tempfile r12
	save `r12'
	}
	
	*Row 13
	{
	use "${dataoutput}DMs.dta", clear
	keep if !regexm(id, "www")
	rename eng_score_tot eng_score
	egen Ndm2=nvals(companyid)
	summ Ndm2
	g k=string(r(mean), "%2.0fc")
	egen Ndm=nvals(id)
	summ Ndm
	g s=string(r(mean), "%2.0fc")
	sum eng_score
	g a=string(r(mean), "%2.1fc")
	g b=string(r(sd), "%2.1fc")
	gen z = 1
	label define eng_dm 1"English score (\%)"
	label values z eng_dm 
	order z a b k s
	keep z a b k s	
	
	tempfile r13
	save `r13'
	}
	
	*Row 14
	{
	use "${dataoutput}Firms_HR_response.dta", clear
	keep if level=="proficient" // decided
	egen Nfm2=nvals(company) if !missing(share_d)
	summ Nfm2
	g k=string(r(mean), "%2.0fc")
	egen Nfm=total(total_d) if total_d>=0
	summ Nfm
	g s=string(r(mean), "%2.0fc")
	replace s= "-"
	sum share_d if total_d>=0
	g a=string(r(mean)*100, "%2.1fc")
	g b=string(r(sd)*100, "%2.1fc")
	gen z = 1
	label define hreng_fm 1 "Share proficient in English (\%) \textdaggerdbl"
	label values z hreng_fm 
	order z a b k s
	keep z a b k s	
	
	tempfile r14
	save `r14'
	}
	
	*Row 15
	{
	use "${dataoutput}Firms_salary_sheets.dta", clear
	*merge m:1 companyid using "${tmp}firms_labor_survey_sample.dta"
	keep if _merge==2 | _merge==3
	keep if pos=="Local; <$200"
	egen Npw=nvals(companyid) if !missing(num)
	summ Npw
	g k=string(r(mean), "%2.0fc")
	egen Npw1=total(num)
	summ Npw1
	g s=string(r(mean), "%2.0fc")
	sum num
	g a=string(r(mean), "%2.1fc")
	g b=string(r(sd), "%2.1fc")
	gen z = 1
	label define w_pw 1"Number \textdagger"
	label values z w_pw
	order z a b k s
	keep z a b k s	
	
	tempfile r15
	save `r15'
	}
	
	*Row 16
	{
	use "${dataoutput}DMs_salary_sheets.dta", clear
	keep if pos=="Local; <$200"
	keep if lang_sample==1
	gen num=1 if !missing(monthly_tot_USD)
	egen Npw=total(num)
	summ Npw
	g s=string(r(mean), "%2.0fc")
	egen Npw2=nvals(companyid) if !missing(monthly_tot_USD)
	summ Npw2
	g k=string(r(mean), "%2.0fc")
	sum monthly_tot_USD
	g a=string(r(mean), "%2.0fc")
	g b=string(r(sd), "%2.1fc")
	gen z = 1
	label define w_pw 1"Monthly Wage (USD) \textdagger"
	label values z w_pw 
	order z a b k s
	keep z a b k s	
	
	tempfile r16
	save `r16'
	}

	*Append rows together
	use `r1', clear
	forval i=2(1)16{
	append using `r`i''
	}
	
	duplicates drop
	drop z
	gen tab_row=_n
	
	*Table
	br
	

/***********************************************************************************/
/****************** Table 2: English Proficiency and Communication *****************/
/***********************************************************************************/

	use "${dataoutput}DMs.dta",clear

	*corrections in data
	drop if regexm(id, "www")
	replace id="egs4571019" if id=="egs4571023" 
	replace id="vqi2101024" if id=="vqi2101026"

	merge 1:1 id using "${dataoutput}DMs_experiment.dta", keepus(Team)
	
	*we do not have teams for full labor survey sample so we construct as company-dept group
	replace Team=100 if _merge==1
	egen Team2=group(companyid deptR0) if _merge==1
	replace Team=Team+Team2 if _merge==1
	drop Team2
	drop _merge
	
	rename id unique_identifier_number
	replace num_direct_reportR0=. if num_direct_reportR0<0
	
	encode(unique_identifier_number), gen(num_man)
	replace mngt_scoreR0=mngt_scoreR0*3
	
	foreach var in  mngt_score involvement_subR0 talk_freq_b log_wage direct_foreignR0 {
	eststo `var': qui reg `var' z_tot  i.education ageR0 tenure experience num_scoreR0 num_score2R0 big* i.company_num , cluster(Team)
	}
			
	keep manager_deid* talk_freq* conversation_60_min_* unique_identifier_number z_tot education ageR0 tenure experience tenure num_scoreR0 num_score2R0 big* P1* P2 P3 P4 dept_* company_num* understand_fraction*
	reshape long manager_deid talk_freq conversation_60_min , i(unique_identifier_number) string
	keep if _j=="_bR0"|_j=="_cR0"|_j=="_aR0"
	gen foreign=(_j=="_bR0"|_j=="_cR0")
	
	*replace fm b with c if b missing
	foreach var in talk_freq conversation_60_min {
	bysort unique_identifier_number (_j): replace `var'=`var'[3] if missing(`var') & _j=="_bR0"
	}
	keep if _j=="_bR0"|_j=="_aR0"
	
	*for domestic managers set as full comprehension and no time lost
	replace conversation_60_min=0 if foreign==0

	gen foreignXz_tot=foreign*z_tot
	encode(unique_identifier_number), gen(num_man)
	replace conversation_60_min=conversation_60_min/60*100
	
	foreach var in talk_freq conversation_60_min {
	eststo `var': qui reghdfe `var' foreign z_tot foreignXz_tot i.company_num, cluster(num_man) a(num_man)
	}
	
	*Table
	esttab log_wage mngt_score involvement_subR0 talk_freq_b direct_foreignR0 talk_freq conversation_60_min, ///
	keep(z_tot foreign foreignXz_tot) compress
	

/***********************************************************************************/
/******************* Table 3: Take-Up and English Proficiency **********************/
/***********************************************************************************/
	
	use "${dataoutput}DMs_experiment.dta", clear
	
	*First stage
	eststo fs1: qui reg Train75 Treated i.strata,  cluster(Team)
	eststo fs3: qui reg Takeup Treated i.strata,  cluster(Team)

	*note: we count these obs as missing speak at baseline so the tot score should reflect just listening
	replace z_speak1=. if missingR0==1
	replace z_tot1=z_eng1 if missingR0==1
	
	foreach var in z_speak z_eng z_tot {
	eststo OLSITT`var': qui reg `var'0 Treated `var'1 i.strata modeEND noEND  missingspeak0,  vce(cluster Team)	
	}
	
	rename Treated instrument
	rename Takeup Treated

	foreach var in z_speak z_eng z_tot {
	eststo OLSTOT`var': qui ivreg2 `var'0 (Treated=instrument) `var'1 i.strata modeEND noEND  missingspeak0, cluster(Team) 
	}
	
	*Table
	esttab fs1 fs3 OLSITTz_tot OLSTOTz_tot OLSITTz_speak OLSTOTz_speak OLSITTz_eng OLSTOTz_eng, keep(Treated) compress


/***********************************************************************************/
/**************************** Table 4: Communication *******************************/
/***********************************************************************************/
	
	use "${dataoutput}DMs_experiment.dta", clear

	*drop outcomes if no endline response
	replace people0=. if noEND==1
	replace target0=. if noEND==1

	foreach var in talkfreqFMB_1 talk_freq_a conv60b {
	eststo OLSITT`var': areg `var'0 Treated `var'1 modeEND noEND , a(strata)  vce (cluster Team)
	}
	
	foreach var in mtg_foreign_first mtg_DM_first {
	eststo OLSITT`var': areg `var'0 Treated  modeEND noEND , a(strata)  vce (cluster Team)
	}
	
	rename Treated instrument
	rename Takeup Treated

	foreach var in talkfreqFMB_1 talk_freq_a conv60b {
	eststo OLSTOT`var': ivreg2 `var'0 (Treated=instrument) `var'1 modeEND noEND  i.strata , cluster(Team ) 
	}
	
	foreach var in mtg_foreign_first mtg_DM_first {
	eststo OLSTOT`var': ivreg2 `var'0 (Treated=instrument)  modeEND noEND  i.strata , cluster(Team) 
	}

	*Table
	esttab OLSITTtalkfreqFMB_1 OLSTOTtalkfreqFMB_1 OLSITTmtg_foreign_first ///
	OLSTOTmtg_foreign_first OLSITTconv60b OLSTOTconv60b   OLSITTtalk_freq_a ///
	OLSTOTtalk_freq_a OLSITTmtg_DM_first OLSTOTmtg_DM_first, keep(Treated) compress
	

/***********************************************************************************/
/********************** Table 5: Management Simulations ****************************/
/***********************************************************************************/
	
	use "${dataoutput}DMs_experiment.dta", clear

	merge 1:m id using "${dataoutput}DMs_mngt_sim.dta", keepusing(task_version time_fm time_worker ///
	time_total mistake question) keep(3) nogen
	
	reshape wide time_fm time_worker time_total mistake question, i(id) j(task_version)
	*1 simple burmese 2 complex burmese 3 complex english.

	foreach var in time_fm time_worker time_total{
	forval i=1(1)3{
	replace `var'`i'=`var'`i'/60
	}
	}

	foreach var in time_worker mistake  time_fm question {
	eststo OLSITT`var': qui reg `var'3 Treated i.strata, cluster(Team2)
	rename Treated instrument
	rename Train75 Treated
	
 	eststo OLSTOT`var': qui ivreg2 `var'3 (Treated=instrument) i.strata, cluster(Team2) 
	rename Treated Train75
	rename instrument Treated
}

	foreach var in time_worker mistake time_fm question {
	eststo OLSITTplacebo`var': qui reg `var'1 Treated i.strata,  cluster(Team2)
	}
	rename Treated instrument
	rename Train75 Treated
	
	foreach var in time_worker mistake time_fm question {
	eststo OLSTOTplacebo`var': qui ivreg2 `var'1 (Treated=instrument)  i.strata, cluster(Team2) 
}
	*Table
	*Panel A
	esttab OLSITTtime_worker OLSTOTtime_worker OLSITTmistake ///
	OLSTOTmistake OLSITTtime_fm OLSTOTtime_fm  OLSITTquestion OLSTOTquestion, keep(Treated) compress
	
	*Panel B
	esttab OLSITTplacebotime_worker OLSTOTplacebotime_worker ///
	OLSITTplacebomistake OLSTOTplacebomistake OLSITTplacebotime_fm ///
	OLSTOTplacebotime_fm  OLSITTplaceboquestion OLSTOTplaceboquestion, keep(Treated) compress
	
	

/***********************************************************************************/
/************** Table 6: Medium-Run Skills and Labor Market Outcomes ***************/
/***********************************************************************************/

	use "${dataoutput}DMs_experiment.dta", clear
	
	*Label skills
	preserve 
	reshape long learning_skills_ , i(id) j(skill_list)
	label define skill_labels 1 "Cognitive skills" ///
	2 "Customer relations" ///
	3 "Financial management/Budget control" ///
	4 "General administrative skills" ///
	5 "Manpower planning" ///
	6 "Marketing strategy" ///
	7 "Supply chain management" ///
	8 "English" ///
	9 "Japanese/Korean" ///
	10 "Excel/Google sheets" ///
	11 "Online tools: Dropbox, Google drive, Zoom/Skype" ///
	12 "Microsoft Outlook/Gmail" ///
	13 "Powerpoint/Google slides" ///
	14 "Tasks specific software: SAP, ERP (Odoo), POS" ///
	15 "Business etiquette" ///
	16 "Confidence" ///
	17 "International business knowledge (kaizen, kanban..)" ///
	18 "Professionalism" ///
	19 "Written communication" ///
	20 "Other" ///
	21 "Total" ///
	22 "DMs"
	label values skill_list skill_labels
	
	gen sb=1 if skill_list==8 | skill_list==9 
	replace sb=4 if skill_list==3|skill_list==4 | skill_list==5 | skill_list==6  | skill_list==7 |skill_list==17
	replace sb=3 if skill_list>=10 & skill_list<=14
	replace sb=2 if missing(sb)
	
	label define skill_bucket 1 "Language" ///
	2 "Soft skill" ///
	3 "Hard skill" ///
	4 "Management" ///
	5 "All"
	
	label values sb skill_bucket
	
	drop if skill_list==20|skill_list==99
	
	forval i=2/4{
	eststo regITT`i': qui reghdfe learning_skills_ Treated if sb==`i', a(strata skill_list)  vce (cluster Team)
	}
	rename Treated instrument
	rename Takeup Treated
	
	forval i=2/4{
	eststo regTOT`i': qui ivreg2 learning_skills_ (Treated=instrument) i.strata i.skill_list if sb==`i' , cluster (Team)
	}
	restore 
	
	preserve
	rename apps_6mR12 applicationsR12
	
	*clean admin outcomes
	gen source="Survey" if noR12==0
	replace source="Sal Sheets" if noR12==1 & !missing(quit_jobR12)
	replace source="Linked In" if id=="zpx1801003" | id=="zpx1801007" | id=="vmy5501005" | id=="fkt9301001" | id=="ics6501012"
	
	rename salary_jan20USD salary_USDR11
	replace salary_USDR11=salary_USDR11/10 if salary_USDR11-salary_USDR12>1000 & regexm(id, "evb")
	replace salary_USDR11=salary_USDR11*10 if id=="evb8451078"
	replace salary_USDR12=salary_USDR12*10 if id=="grx3161006"
	replace salary_USDR12=salary_USDR12*10 if id=="gxx9691003"
	
	gen lsalary_USDR12=log(salary_USDR12)
	gen lsalary_USDR11=log(salary_USDR11)
	gen lsalary_USDR0=log(salary_USD1)

	gen wave2=wave
	replace wave2=1 if missing(wave) & !missing(quit_jobR12)
	encode source, gen(source1)
	
	gen missingSalary=missing(lsalary_USDR0)
	replace lsalary_USDR0=0 if missing(lsalary_USDR0)
	rename applications0 applicationsR11

	replace quit_jobR12=1 if quit_job0==1
	keep applications* Treated Takeup id  strata Team source1 salary_USDR* missingSalary lsalary_USDR* wave2 modeEND quit_jobR*
	rename *R11 *Rd11
	rename *R12 *Rd12
	reshape long applicationsRd salary_USDRd lsalary_USDRd quit_jobRd, i(id) j(round)

	collapse (mean) applicationsRd salary_USDRd (max) quit_jobRd, by(id Treated Takeup Team missingSalary strata lsalary_USDR0)
	
	gen lsalary_USDRd=log(salary_USDRd)
	
	foreach var in quit_job applications lsalary_USD  {
	eststo vOLSITT`var': qui reg `var'Rd Treated  i.strata   lsalary_USDR0 missingSalary ,  vce(cluster Team)
	}
	
	rename Treated instrument
	rename Takeup Treated
	
	foreach var in quit_job applications lsalary_USD {
	eststo vOLSTOT`var': qui ivreg2 `var'Rd ( Treated= instrument) i.strata lsalary_USDR0 missingSalary, cluster(Team) 
	}
	restore
	
	*Table
	*Panel A
	esttab  regITT2 regTOT2 regITT3 regTOT3 regITT4 regTOT4, keep(Treated) compress
	
	*Panel B
	esttab vOLSITTlsalary_USD vOLSTOTlsalary_USD vOLSITTquit_job vOLSTOTquit_job vOLSITTapplications vOLSTOTapplications, keep(Treated)
	

/***********************************************************************************/
/*********** Table 7: Characteristics Valued by HR Managers: Demographics **********/
/***********************************************************************************/

	use "${dataoutput}Resume_data.dta", clear

	drop if o_pilot==1
	keep if company_origin==1 // only local firms
	la var chosen_cv "Pick 1"
	la var wage_usd "Wage offer"
	la var learn_job "Learning"
	la var inv_ppl "Inv Ppl"
	la var inv_factory "Inv Fact"
	
	eststo reg1wage: qui reghdfe wage_usd i.ENGLISH##i.FDI  i.GENDER i.AGE i.FIRM_SIZE i.WORK_EX if exp==1, a(RATER pairs) vce(cluster RATER)

	eststo reg1learn: qui reghdfe learn_job i.ENGLISH##i.FDI  i.GENDER i.AGE i.FIRM_SIZE i.WORK_EX if exp==1, a(RATER pairs) vce(cluster RATER)

	egen inv_mean=rmean(inv_ppl inv_factory)
	eststo reg1inv: qui reghdfe inv_mean i.ENGLISH##i.FDI  i.GENDER i.AGE i.FIRM_SIZE i.WORK_EX if exp==1, a(RATER pairs) vce(cluster RATER)
	
	*Table
	esttab reg1wage reg1inv reg1learn, ///
	keep(1.ENGLISH 1.FDI 1.ENGLISH#1.FDI 2.AGE 2.GENDER 2.FIRM_SIZE 2.WORK_EX) compress


/***********************************************************************************/
/******* Table 8: Characteristics Valued by HR Managers: Interview Responses *******/
/***********************************************************************************/

	use "${dataoutput}Resume_data.dta", clear
	
	drop if o_pilot==1
	keep if company_origin==1 // only local firms
	la var chosen_cv "Pick 1"
	la var wage_usd "Wage offer"
	la var learn_job "Learning"
	la var inv_ppl "Inv Ppl"
	la var inv_factory "Inv Fact"
	
	eststo reg2b: qui reghdfe wage_usd i.COMMUNICATION i.MICROSOFT_OFFICE i.TARGET if exp==2, a(RATER pairs) vce(cluster RATER)
	eststo reg2c: qui reghdfe learn_job i.COMMUNICATION i.MICROSOFT_OFFICE i.TARGET if exp==2, a(RATER pairs) vce(cluster RATER)

	esttab reg2b reg2c, keep(1.COMMUNICATION 2.COMMUNICATION 2.MICROSOFT_OFFICE 2.TARGET) compress
